package opeartion;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书!");
        Scanner in=new Scanner(System.in);
        System.out.println("请输入你想要查找的图书的名字：");
        String name=in.nextLine();
        int size=bookList.getUsedSize(),i;
        for (i = 0; i < size; i++) {
            Book book= bookList.getBooks(i);
            if (name.equals(book.getName())){
                System.out.println("查找成功");
                System.out.println(book);
                return;
            }
        }
            System.out.println("当前图书馆中没有你想要的图书");
    }
}
